﻿Imports DTO
Imports System.Data.SqlClient

Public Class DonViDAO

    Public Shared Function LayDSDonViCbx() As DataTable
        Return CKetNoi.GetData("select MaDonVi, TenDonVi from DonVi")
    End Function

    Public Shared Function LayDSDonVi() As DataTable
        Return CKetNoi.GetData("LayDSDonVi")
    End Function

    Public Shared Function ThemDonVi(dv As DonViDTO) As Integer
        Dim kt As Integer
        Dim lst As New List(Of SqlParameter)
        lst.Add(New SqlParameter("@tenDV", dv.TenDonVi))
        lst.Add(New SqlParameter("@maTT", dv.MaTrangThai))
        lst.Add(New SqlParameter("@ghichu", dv.GhiChu))
        kt = CKetNoi.ExecQueryStoreProc("ThemDonVi", lst)
        Return kt
    End Function

    Public Shared Function CapNhatDonVi(dv As DonViDTO) As Integer
        Dim kt As Integer
        Dim lst As New List(Of SqlParameter)
        lst.Add(New SqlParameter("@maDV", dv.MaDonVi))
        lst.Add(New SqlParameter("@tenDV", dv.TenDonVi))
        lst.Add(New SqlParameter("@maTT", dv.MaTrangThai))
        lst.Add(New SqlParameter("@ghichu", dv.GhiChu))
        kt = CKetNoi.ExecQueryStoreProc("CapNhatDonVi", lst)
        Return kt
    End Function

    Public Shared Function XoaDonVi(dv As DonViDTO) As Integer
        Dim kt As Integer
        Dim lst As New List(Of SqlParameter)
        lst.Add(New SqlParameter("@maDV", dv.MaDonVi))
        kt = CKetNoi.ExecQueryStoreProc("XoaDonVi", lst)
        Return kt
    End Function


End Class
